
Chapter 11. Building a Game Pad Controller with JInput

From:
  Pro Java 6 3D Game Development
  Andrew Davison
  Apress, April 2007
  ISBN: 1590598172 
  http://www.apress.com/book/bookDisplay.html?bID=10256
  Web Site for the book: http://fivedots.coe.psu.ac.th/~ad/jg2

Contact Address:
  Dr. Andrew Davison
  Dept. of Computer Engineering
  Prince of Songkla University
  Hat Yai, Songkhla 90112, Thailand
  E-mail: ad@fivedots.coe.psu.ac.th


If you use this code, please mention my name, and include a link
to the book's Web site.

Thanks,
  Andrew

=============================================
Three Simple Examples

* ListControllers
    - it prints a list of all the detected input devices.

* ControllerDetails
    - it outputs a list of all of the components that form 
      part of a specified controller

* TestController
   - this displays the numbers generated by a given component 
     as the user manipulates it


=============================================
Software/Hardware You Need

* The JInput API for Windows, available from 
  https://jinput.dev.java.net. Look in the Win32 folder 
  under the "Documents & Files" menu item.
  
* A game pad: the GamePadViewer application assumes there is a 
  device with two analog sticks, a hat, 12 buttons, and rumbler
  support attached to the machine. 

  Read the chapter to see how to check out the game pad in
  Windows and DirectX before you start with JInput.


=============================================
Compilation: 

Use the compileJI.bat batch file.
    // make sure you have JInput installed

$ compileJI ListControllers.java

$ compileJI ControllerDetails.java

$ compileJI TestController.java

or the lot in one go:

$ compileJI *.java


compileJI.bat assumes the JInput library files are located
in d:\jinput\bin. Change the batch file to match where you've
placed the files.

=============================================
Execution: 

Use the runJI.bat batch file.
    // make sure you have JInput installed

$ runJI ListControllers


$ runJI ControllerDetails <controller-num> [<file>]
e.g.
$ runJI ControllerDetails 2
$ runJI ControllerDetails 1 keysInfo.txt


$ runJI TestController <controller-num> <component-num>
e.g.
$ runJI TestController 2 0


runJI.bat assumes the JInput library files are located
in d:\jinput\bin. Change the batch file to match where you've
placed the files.

---------
Last updated: 4th March 2007